#include<cstdio>
#include<algorithm>

using namespace std;
const int maxn=1e5+10;
int a[maxn];

int main()
{
    int sum=0,ans=0,n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
    	sum+=a[i];
    	min(ans,ans+sum); 
	}
	printf("%d",sum-ans);
    return 0;
}
